package lv.servidordisqueria.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class ServidorDisqueria {

	private static final Integer PORT = 10101;
	private static ServerSocket serverSocket;

	public static void main(String[] args) {
		System.out.println("##################ARRANCO EL SERVIDOR........");
		Socket socket = null;
		try {
			serverSocket = new ServerSocket(PORT);
			while (true){
				socket = serverSocket.accept();
				System.out.println("##################EJECUTA PEDIDO........");
				new ServidorConsultor(socket);
			}
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("entro en el cacht 1");
		} finally {
			try {
				socket.close();
				serverSocket.close();
				System.out.println("##################TERMINO PEDIDO........");
			} catch (IOException e) {
				e.printStackTrace();
				System.out.println("entro en el cacht 2");
			}
		}
	}
}
